﻿@Html.DevExpress().Scheduler(
        settings => 
        {

         settings.Name = "scheduler";
            settings.CallbackRouteValues = new { Controller = "Calendar", Action = "ReportTemplatesPartial" };
            settings.EditAppointmentRouteValues = new { Controller = "Calendar", Action = "CustomFormsPartialEditAppointment" };
            settings.ActiveViewType = SchedulerViewType.Month;
            settings.GroupType = SchedulerGroupType.None;
           // settings.Start = new DateTime(2010, 7, 13);
            //改为当前月第一天
            settings.Start =Session["time"] == null ? DateTime.Now : DateTime.Parse(Session["time"].ToString());
            settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
            settings.Height=System.Web.UI.WebControls.Unit.Percentage(100);
            settings.OptionsForms.RecurrenceFormName = "appointmentRecurrenceForm";
            settings.Views.DayView.ResourcesPerPage = 3;
            settings.Views.DayView.Styles.ScrollAreaHeight = System.Web.UI.WebControls.Unit.Pixel(300);
            settings.Views.WorkWeekView.ResourcesPerPage = 3;
            settings.Views.WorkWeekView.Styles.ScrollAreaHeight = System.Web.UI.WebControls.Unit.Pixel(300);
            settings.Views.WeekView.ResourcesPerPage = 3;
            settings.Views.MonthView.ResourcesPerPage = 3;
            settings.Views.TimelineView.ResourcesPerPage = 3;
            settings.Views.MonthView.AppointmentDisplayOptions.TimeDisplayType = AppointmentTimeDisplayType.Text;
            settings.Views.MonthView.Styles.DateCellBody.Height = System.Web.UI.WebControls.Unit.Pixel(40);
            
         
          
           //nav按钮caption
            settings.OptionsView.NavigationButtons.NextCaption = "下一个日历项";
            settings.OptionsView.NavigationButtons.PrevCaption = "上一个日历项";
            
            //屏蔽跳转到某一天
          //  settings.OptionsForms.GotoDateFormVisibility = SchedulerFormVisibility.None;
          
            settings.PopupMenuShowing = (sender, e) => {

                e.Menu.Items.RemoveAll(h => h.Text == "显示时间为");
                e.Menu.Items.RemoveAll(h => h.Text == "标记为");

               
                  // s.RemoveAll(h=>h.==SchedulerMenuItemId.LabelSubMenu);
                       
               
            
            };
            settings.SetToolbarViewVisibleIntervalTemplateContent(c =>
                {
                    
                    ViewContext.Writer.Write(c.Scheduler.SelectedInterval.Start.ToString("yyyy年MM月dd日"));
                });
            settings.Views.WeekView.ShortDisplayName = "星期";
            settings.Views.WeekView.DisplayName= "星期";
            settings.Views.DayView.ShortDisplayName="天";
             settings.Views.DayView.DisplayName ="天";
             settings.Views.MonthView.DisplayName = "月";
            settings.Views.MonthView.ShortDisplayName = "月";
            settings.Views.TimelineView.ShortDisplayName = "时间";
            settings.Views.TimelineView.DisplayName="时间";
            settings.Views.WorkWeekView.ShortDisplayName = "工作日";
            settings.Views.WorkWeekView.DisplayName = "工作日";
            settings.Views.TimelineView.Enabled = false;
            //settings.OptionsForms.RecurrentAppointmentEditFormVisibility = SchedulerFormVisibility.None;
         // settings.OptionsCustomization.AllowAppointmentCreate = UsedAppointmentType.None;
            settings.OptionsCustomization.AllowAppointmentEdit = UsedAppointmentType.All;
           settings.OptionsCustomization.AllowInplaceEditor = UsedAppointmentType.None;
           settings.PrepareAppointmentFormPopupContainer = (s, e) =>
           {

               e.Popup.HeaderText = "日历编辑";
           };
           // settings.OptionsCustomization.AllowAppointmentDelete = UsedAppointmentType.None; 
            settings.OptionsForms.SetAppointmentInplaceEditorFormTemplateContent(c =>
                {
                    
                    ViewContext.Writer.Write("");
                });
            settings.Storage.EnableReminders = false; ;
            settings.Storage.Appointments.Assign(ElingOA6_Admin_DSJCJ.Areas.Admin.Controllers.SchedulerDemoHelper.DefaultAppointmentStorage);
            settings.Storage.Resources.Assign(ElingOA6_Admin_DSJCJ.Areas.Admin.Controllers.SchedulerDemoHelper.DefaultResourceStorage);
            //settings.OptionsCustomization.AllowAppointmentCreate = UsedAppointmentType.Custom;
            //settings.OptionsCustomization.AllowAppointmentEdit = UsedAppointmentType.Custom;
            //settings.OptionsCustomization.AllowAppointmentDelete = UsedAppointmentType.Custom;
            settings.OptionsForms.SetAppointmentFormTemplateContent(c =>
            {
              
                c.ID = "aptform";
                var container = c;
                var schedule = new ElingOA6_Admin_DSJCJ.Model.Calendar
                {
                  
                    FCalendarID = container.Appointment.Id== null ? -1:(decimal)container.Appointment.Id ,
                    FTitle = container.Appointment.Subject,
                    WakeStr = container.Appointment.Id == null ? (container.Appointment.AllDay ? "18h" : "15m") : (string.IsNullOrEmpty(container.Appointment.CustomFields["WakeStr"].ToString()) ? "none" : container.Appointment.CustomFields["WakeStr"].ToString()),
                    FBeginDate = container.Appointment.Start.Hour == 0 & container.Appointment.End.Hour == 0 & container.Appointment.Start.Minute == 0 & container.Appointment.End.Minute == 0 & !container.Appointment.AllDay & container.Appointment.Id == null ? container.Appointment.Start.AddHours(8) : container.Appointment.Start,
                    FEndDate = container.Appointment.End.Hour == 0 & container.Appointment.End.Minute == 0 & container.Appointment.Start.Hour == 0 & container.Appointment.Start.Minute == 0 & !container.Appointment.AllDay & container.Appointment.Id == null ? container.Appointment.End.AddHours(8).AddMinutes(30).AddDays(-1) : (container.Appointment.AllDay ? container.Appointment.End.AddDays(-1) : container.Appointment.End),
                    FContents = container.Appointment.Description,
                 FIsAllDayEvent=container.Appointment.AllDay?"Y":"N",
                    FIsWake =container.Appointment.CustomFields["isremind"]==null?"N": container.Appointment.CustomFields["isremind"].ToString(),
               FPri=container.Appointment.CustomFields["FPri"]==null?"2":container.Appointment.CustomFields["FPri"].ToString()
                };
                ViewBag.delvisible = container.Appointment.Id == null?false:true;
                Html.RenderPartial("CustomAppointmentFormPartial", schedule);
            });

            settings.AppointmentFormShowing = (sender, e) =>
            {
                var scheduler = sender as MVCxScheduler;
                if (scheduler != null)
                    e.Container = new AppointmentFormTemplateContainer(scheduler);
            };
            //settings.OptionsForms.SetRemindersFormTemplateContent(c =>
            //    {
                    
                        
            //        var apts = c.Reminders.Select(h => h.Appointment).ToList();
            //        Html.RenderPartial("RemindersFormPartial", apts);
            //    });
         //settings.OptionsForms.SetAppointmentFormTemplateContent("c =>"        );

        }).Bind(Model.Appointments, Model.Resources).GetHtml()
